<?php

/**
 * task actions.
 *
 * @package    raidpoints
 * @subpackage task
 * @author     David Driscoll
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class dotaskActions extends sfActions
{
    public function executeIndex(sfWebRequest $request)
    {
        return $this->renderText("updated");;
    }

    public function executeStartimport(sfWebRequest $request)
    {
        $bg = new BackgroundIt();
        $bg->sys(sfConfig::get('sf_root_dir')."/symfony raidpoints:importRun", sfConfig::get("app_path_to_php"));
        return $this->renderText("updated");
    }

    public function executeStartarmory(sfWebRequest $request)
    {
        $bg = new BackgroundIt();
        $bg->run(sfConfig::get('sf_root_dir').'/symfony raidpoints:armory-run', sfConfig::get("app_path_to_php"));
        return $this->renderText("updated");
    }

    public function executeClearimporthistory(sfWebRequest $request)
    {
        $q = Doctrine::getTable("DataImportStatus")
            ->createQuery()->delete()->where("1=1");
        $q->execute();
        return $this->renderText($q->getDql());
    }

    public function executeCleararmoryhistory(sfWebRequest $request)
    {
        $q = Doctrine::getTable("DataSyncStatus")
            ->createQuery()->delete();
        $q->execute();
        return $this->renderText("updated");
    }
    public function executeClearimport(sfWebRequest $request)
    {
        $q = Doctrine::getTable("DataImport")
            ->createQuery()->delete();
        $q->execute();
        return $this->renderText("updated");
    }

    public function executeCleararmory(sfWebRequest $request)
    {
        $q = Doctrine::getTable("DataSync")
            ->createQuery()->delete();
        $q->execute();
        return $this->renderText("updated");
    }

    public function executeUpdatepoints(sfWebRequest $request)
    {
        Doctrine::getTable("PlayerHistory")->updatePoints();
        return $this->renderText("updated");
    }

    public function executeClearpagecache(sfWebRequest $request)
    {
        $q = Doctrine::getTable("CachePlayerHistory")
                    ->createQuery()->delete();
        $q->execute();

        $q = Doctrine::getTable("CacheRaidHistory")
                    ->createQuery()->delete();
        $q->execute();
        return $this->renderText("updated");
    }
}
